import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
import Info from './info'
// ===================================================================== Declare
const { $fn, $http } = window
// ===================================================================== Lazy
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		selectedKeys:[],
		// 搜索表单列表
		forms : this.props.forms,
		info: '',
		file: ''
	}
	
	model = {}
	
	componentDidMount(){
		this.fetch()
	}
	
	// paging
	fetch = () => $fn.fetch.call(this,'work-event/index', { param: {send:0, status:-1} })
	
	render(){
		const { info, file } = this.state
		return (
			<>
				{/* 搜索 */}
				{ SearchForm.call(this) }
				<div className='fx h'>
					{/* 表格 */}
					{ Table.call(this, { cols:this.props.cols, onRow:({uuid}) => {
						$http.submit(null, 'work-event/info', { param: {uuid} }).then(({content,url}) => this.setState({info: content, file: url}))
					}, onRowClass: ({ is_time_out }) => +is_time_out ? 'g9' : '' }) }
					{/* 信息 */}
					<div className='fv' style={{width: 340}}>
						<Info info={info} />
						{/* 新增附件展示 2022年11月7日16:45:58 敖得卓 */}
						<Info info={
							`<a href=${file} target="_blank" style={{ maxWidth: '100%',display:'block', marginTop: '20px' }}>${file || ''}</a>`
						} title="附件" />
					</div>
				</div>
			</>
		)
	}
}

export default Index